<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use common\models\business\BusinessPigPriceDetail;
use common\models\business\BusinessPigPriceType;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\business\models\BusinessPigPriceDetailSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '分割库存';
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
            <?= Html::a('返回','javascript:history.back(-1)'); ?>
            <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">
 


<div class="business-pig-price-detail-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <?php
    echo \kartik\grid\GridView::widget([
        'dataProvider'=>$dataProvider,
        'filterModel'=>$searchModel,
        'showPageSummary'=>true,
        'pjax'=>true,
        'striped'=>true,
        'hover'=>true,
        'panel'=>['type'=>'primary', 'heading'=>'分割库存'],
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns'=>[
            [
                'label' => '所属分割编号',
                'attribute'=>'pigprice.number',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'pig.no',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'type',
                'width'=>'80px',
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=> $types,
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'类型']
            ],
            [
                'attribute'=>'price',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
                'format'=>['decimal', 2],
                'pageSummary'=>true,
            ],
            [
                'attribute'=>'unit',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=> $units,
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'销售单位']
            ],

            [
                'attribute'=>'weight',
                'value' => function($model){
                    return $model->weight;
                },
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
                'format'=>['decimal', 2],
                'pageSummary'=>true,
            ],

            [
                'attribute'=>'status',
                'width'=>'80px',
                'format' => 'raw',
                'value'=>function ($model, $key, $index, $widget) {
                    $txt = BusinessPigPriceDetail::$statues[$model->status];
                    if($model->status == BusinessPigPriceDetail::STATUS_SELL){
                        return Html::button($txt,['class'=>'btn btn-success btn-xs']);
                    }else{
                        return Html::button($txt,['class'=>'btn btn-default btn-xs']);
                    }
                },
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=> BusinessPigPriceDetail::$statues,
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'是否已经售卖']
            ],
            [
                'attribute'=>'createtime',
                'value' => function($model){
                    return date('Y-m-d',$model->createtime);
                },
                'width'=>'200px',
                'hAlign'=>'right',
                'filterType' => GridView::FILTER_DATE_RANGE,
                'filterWidgetOptions' =>([
                    'attribute'=>'planout',
                    'presetDropdown'=>false,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'separator'=>'至',
                        'format'=>'Y-m-d',
                        'opens'=>'left',
                    ],
                ])
            ],
            [
                'class' => '\kartik\grid\ActionColumn',
                'deleteOptions' => ['label' => '<i class="glyphicon glyphicon-remove"></i>'],
                'template' => '{view}{update}{agree}{disagree}',
                'buttons' => [
                    'view' => function ($url, $model) {
                        return Html::a('详情|',\yii\helpers\Url::to(['view','id'=>$model->id]),[
                            'title' => '详情','class'=>'view','data-id'=>$model->id,
                        ]);
                    },
                    'update' => function ($url, $model) {
                        return Html::a('更新',\yii\helpers\Url::to(['update','id'=>$model->id]),[
                            'title' => '更新','class'=>'update','data-id'=>$model->id,
                        ]);
                    }
                ],
            ],
        ],
        'toolbar'=> [
            '{export}',
            '{toggleData}',
        ],
        'bordered'=>true,
        'condensed'=>true,
    ]);
    ?>

</div>
</div>
</div>
</section>
</section>





